<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>支付</title>
</head>
<script src="/jquery/jquery.min.js"></script>
<script src="/utils/TimeUtil.js"></script>
<script src="/utils/HttpUtil.js"></script>
<script>
	var params = {};
	function payOrder() {
		$.get("/wechat/pay", {
			orderId : getQueryString('orderId'),
			utoken : getQueryString('utoken')
		}, function(data, status) {
			console.log("下单返回结果:" + JSON.stringify(data));
			params = data;
			onBridgeReady();
		});
	}

	function onBridgeReady() {
		WeixinJSBridge.invoke('getBrandWCPayRequest', params, function(res) {
			if (res.err_msg == "get_brand_wcpay_request:ok") {
				// 使用以上方式判断前端返回,微信团队郑重提示：
				//res.err_msg将在用户支付成功后返回ok，但并不保证它绝对可靠。
			}
		});
	}
	if (typeof WeixinJSBridge == "undefined") {
		if (document.addEventListener) {
			document.addEventListener('WeixinJSBridgeReady', onBridgeReady,
					false);
		} else if (document.attachEvent) {
			document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
			document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
		}
	} else {
		onBridgeReady();
	}
</script>
<body>
	<h2 id="curPath"></h2>
	<button onclick="payOrder()">支付</button>
</body>
</html>